package Thread;
/**
 * 10张票分给了三个窗口，共同完成
 * */
class MyThread2 implements Runnable{
    private int ticket =10;
    private String name;
    public void run(){
        for(int i =0;i<500;i++){
            if(this.ticket>0){
                System.out.println(Thread.currentThread().getName()+"卖票---->"+(this.ticket--));
            }
        }
    }
}
public class demo2Runnable {

    public static void main(String[] args) {
        //设计三个线程
        MyThread2 mt = new MyThread2();
        Thread t1 = new Thread(mt,"一号窗口");
        Thread t2 = new Thread(mt,"二号窗口");
        Thread t3 = new Thread(mt,"三号窗口");
        t1.start();
        t2.start();
        t3.start();
    }

}
